<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>比较两个数的大小</title>
    <script src="../../Desktop/vue.js"></script>
    <style>
        .compare{
            margin: auto;
            width: 500px;
        }
        ul{
            padding: 0;

        }
        ul li {
            list-style: none;
            margin-top: 20px;
        }
    </style>
</head>
<body>
    <div id="app">
        <div class="compare">
            <ul>
                <li>请输入第一个数：<input type="text"></li>
                <li>请输入第二个数：<input type="test"></li>
                <li><button @click="compare">比较</button></li>
                <li>得出结论：{{result}}</li>
            </ul>

        </div>

    </div>
    <script>
        var vm = new Vue({
            el:'#app',
            data:{
                num1:'',
                num2:'',
                result:'',
            },
            methods:{
                compare(){
                    console.log(this.num1)
                    console.log(this.num2)
                    if (!this.num1 || !this.num2){
                        this.result="请正确输入数据"
                    }
                    else{
                        if (this.num1>this.num2){
                            this.result="第一个数大于第二个数"
                        }
                        if (this.num1==this.num2){
                            this.result="第一个数等于第二个数"
                        }
                        if (this.num1<this.num2){
                            this.result="第一个数小于第二个数"
                        }
                    }
                }
            }
        })
    </script>
    
</body>
</html>